//
//  KABillListSectionHeader.swift
//  kano
//
//  Created by Frank on 2024/10/11.
//

import UIKit
import ActiveLabel

class KABillListSectionHeader: UITableViewHeaderFooterView {
    
    var handler: (()->())?
    
    lazy var var_bgView: UIView = {
        let var_bgView = UIView()
        var_bgView.backgroundColor = .colorF6F6F6
        //        var_bgView.layer.cornerRadius = 10
        //        var_bgView.layer.masksToBounds = true
        return var_bgView
    }()
    
    lazy var tipTitle: ActiveLabel = {
        tipTitle = ActiveLabel()
        let customType = ActiveType.custom(pattern: "go to complain")
        tipTitle.enabledTypes = [customType]
        tipTitle.numberOfLines = 0
        tipTitle.text = "If you encounter illegal collection, poor collection attitude, etc., you can contact us to complain and go to complain >>"
        //tipTitle.lineSpacing = kscale(8)
        tipTitle.font = UIFont.systemFont(ofSize: kscale(11), weight: .medium)
        tipTitle.customColor[customType] = .colorFF8921
        tipTitle.textColor = .color8A8891
        tipTitle.handleCustomTap(for: customType, handler: { [self] (customType) in
            if handler != nil {
                handler!()
            }
        })
        return tipTitle
    }()
    
    
    override init(reuseIdentifier: String?) {
        super.init(reuseIdentifier: reuseIdentifier)
        contentView.backgroundColor = .white
        ka_setUI()
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    func ka_setUI() {
        backgroundColor = .white
        contentView.addSubview(var_bgView)
        var_bgView.addSubview(tipTitle)
        
    }
    
    override func layoutSubviews() {
        super.layoutSubviews()
        
        var_bgView.snp.makeConstraints { make in
            make.left.equalTo(kscale(12));
            make.right.equalTo(kscale(-12));
            make.top.bottom.equalTo(contentView);
            //            make.height.equalTo(kscale(75))
        }
        
        tipTitle.snp.makeConstraints { make in
            make.top.left.equalTo(kscale(10))
            make.right.equalTo(kscale(-10));
        }
        
        var_bgView.ka_addTopCorner(withRadius: 10)
    }
    
}

